var array1 = [1, 2, 4, 45, 6];
var target = 3;
function twoSum1(arr, target) {
  var hash = {};
  for (var i = 0; i < arr.length; i++) {
    var rest = target - arr[i];
    if (hash[rest]) {
      return [i, hash[rest]];
    } else {
      hash[rest] = i;
    }
  }
  return false;
}
console.log(twoSum1(array1, target));
